﻿using RXY_Mall.AdminApi.Common;
using RXY_Mall.Data;
using RXY_Mall.Services;
using RXY_Mall.Services.Goods;
using RXY_Mall.Services.Goods.Dto;
using System.Threading.Tasks;
using System.Web.Http;

namespace RXY_Mall.AdminApi.Controllers
{
    /// <summary>
    /// 商品接口
    /// </summary>
    [RoutePrefix("Goods")]
    [ApiSecurityFilter]
    public partial class GoodsController : BaseApiController
    {
        private RXY_MallContext db;
        private IGoodsService goodsService;

        /// <summary>
        /// 缓存时间 单位s
        /// </summary>
        public const int CACHETIME = 5;

        public GoodsController()
        {
            db = new RXY_MallContext();
            goodsService = new GoodsService();
        }

        /// <summary>
        /// 批量添加分类
        /// </summary>
        /// <param name="input">分类输入信息</param>
        [HttpPost]
        [Route("AddCategories")]
        public async Task<ResponseService<bool>> AddCategories(AddCategoriesInput input)
        {
            return await goodsService.AddCategories(input);
        }

        /// <summary>
        /// 批量添加品牌
        /// </summary>
        /// <param name="input">品牌输入信息</param>
        [HttpPost]
        [Route("AddBrands")]
        public async Task<ResponseService<bool>> AddBrands(AddBrandsInput input)
        {
            return await goodsService.AddBrands(input);
        }

        /// <summary>
        /// 批量添加商品
        /// </summary>
        /// <param name="input">商品输入信息</param>
        [HttpPost]
        [Route("AddGoods")]
        public async Task<ResponseService<bool>> AddGoods(AddGoodsInput input)
        {
            return await goodsService.AddGoods(input);
        }

    }
}
